package com.wechat.back.mapper;

import com.wechat.back.pojo.inform.NoticeData;
import com.wechat.back.pojo.inform.NoticeType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NoticeMapper {
    @Select("select * from notice_data order by create_time desc")
    List<NoticeData> noticeList();

    @Select("select * from notice_type")
    List<NoticeType> typeList();

    @Insert("insert into notice_data(notice_title, notice_content, notice_type, create_time, update_time)" +
            "values (#{noticeTitle},#{noticeContent},#{noticeType},#{createTime},#{updateTime})")
    void addNotice(NoticeData noticeData);

    @Insert("insert into notice_type(notice_type, type_desc, create_time, update_time)" +
            "values (#{noticeType},#{typeDesc},#{createTime},#{updateTime})")
    void addType(NoticeType noticeType);

    @Update("update notice_data set notice_title=#{noticeTitle}, notice_content=#{noticeContent},notice_type=#{noticeType},update_time=#{updateTime} where id=#{id}")
    void updateNotice(NoticeData noticeData);

    @Update("update notice_type set notice_type=#{noticeType}, type_desc=#{typeDesc}, update_time=#{updateTime} where id=#{id}")
    void updateType(NoticeType noticeType);

    @Delete("delete from notice_data where id=#{id}")
    void deleteNotice(Integer noticeId);

    @Delete("delete from notice_type where id=#{id}")
    void deleteType(Integer typeId);
}
